//
//  DHNetAPIClient.m
//  Dresshere
//
//  Created by ZhangPeng on 2017/12/28.
//  Copyright © 2017年 张朋. All rights reserved.
//

#import "DHNetAPIClient.h"
#import "BaseModel.h"
#import "DHNoLoginViewController.h"
#import "Error.h"

#define kNetworkMethodName @[@"Get", @"Post", @"Put", @"Delete"]

@implementation DHNetAPIClient

static DHNetAPIClient *_shareClient = nil;
static dispatch_once_t onceToken;

+ (DHNetAPIClient *)shareDHNetAPIClient{
    dispatch_once(&onceToken, ^{
        _shareClient = [[DHNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kHost]];
    });
    return _shareClient;
}

- (id)initWithBaseURL:(NSURL *)url {
    self = [super initWithBaseURL:url];
    if (!self) {
        return nil;
    }
    
    self.requestSerializer = [AFJSONRequestSerializer serializer];
    
    self.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/plain", @"text/javascript", @"text/json", @"text/html", nil];
    
    return self;
}

#pragma mark - 获取当前最新版本号
- (void)request_versionAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/version" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_upyun_signatureWithParams:(NSDictionary *)dic andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/upyun/signature" withParams:dic  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 获取支持商旅专送的城市列表
- (void)request_supportCitiesAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/supportCities" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 获取物流类别
- (void)request_logisticsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/logistics" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_colorsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/colors" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 获取所有风格列表
- (void)request_stylesAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/styles" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_payment_statusWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/status" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 发送验证码
- (void)request_smscodeWithPhone:(NSString *)phone AndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/smscode" withParams:@{@"phone":phone}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_app_searchWithParams:(NSDictionary *)params AndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/app/search" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_app_adWithParams:(NSDictionary *)params AndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/ads" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brands_hotWithParams:(NSDictionary *)params AndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brands/hot" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 使用短信验证码登录
- (void)request_loginWithPhone:(NSString *)phone code:(NSString *)code andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/smscode/login" withParams:@{@"phone":phone, @"code":code}  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_wechat_loginWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/wechat/login" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_supplement_phoneWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/supplement/phone" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 设置用户身高年龄体重
- (void)request_bodyWithWeight:(NSString *)weight height:(NSString *)height age:(NSString *)age andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/body" withParams:@{@"weight":weight, @"height":height, @"age":age}  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_stylesWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/styles" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_measureWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/measure" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_photoWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/photo" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_nicknameWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/nickname" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_sexWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/sex" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 获取用户基本信息
- (void)request_basicInfoAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/basicInfo" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_likeAndOrigin:(NSString *)origin andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/like" withParams:@{@"origin":origin}  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_likeParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/collects" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_address_recentAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/addresses" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_vipAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_products_returnAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/products/return" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_consultParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/consult" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_measure_lastAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/measure/last" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_consult_lastAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/consult/last" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_depositAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/deposit" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_addressAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/addresses" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_lease_lastAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/lease/last" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brandsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brands" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brands_recommend_designersWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brands/recommend/designers" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brands_detailWithParams:(NSDictionary *)params AndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brand/detail" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_category_sizes_nameWithCategoryID:(NSString *)categroy_id andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/category/sizes/name" withParams:@{@"category_id":categroy_id}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_search_productsWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/products" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_detailWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/detail" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_sizesWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/sizes" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brands_products_countWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brand/content/count" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_relatedWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/related" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_cart_countAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cart/count" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_product_collectWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/product/collect" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brand_collectWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brand/collect" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_brand_remarkWithDictionary:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/brand/remark" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_cart_addWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cart/add" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_cart_modify_countWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cart/modify/count" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_cart_deleteWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cart/delete" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_cartAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cart" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_orders_validWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/orders/valid" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_orders_createWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/orders/create" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_couponsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/coupons" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_coupons_valid_countWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/coupons/valid/count" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_precreateWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/precreate" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_confirmWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/confirm" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_receiverWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/receiver" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_washing_returnWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/washing/return" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_expressWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/express" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_couponWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/coupon" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_apply_returnWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/apply/return" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_ordersWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/orders" withParams:params withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_orders_detailWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/detail" withParams:params withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_returnAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/products/return" withParams:@{} withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_returnWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/products/return" withParams:params withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_order_compensateWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/order/compensate" withParams:params withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_vipLevelsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip/levels" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_vip_purchaseWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip/purchase" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_vip_promotionAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip/promotion" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_address_createWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/address/create" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_address_deleteWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/address/delete" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_address_modifyWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/address/modify" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_vip_satisfyAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip/satisfy" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_vip_priceWithVip_id:(NSString *)vip_id andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip/price" withParams:@{@"vip_id":vip_id}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_vipAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/vip" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_coversAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/covers" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_categoriesWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/categories" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_scenesAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/scenes" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_logoutAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/logout" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articlesPageIndex:(NSNumber *)pageIndex pageSize:(NSNumber *)pageSize andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles" withParams:@{@"pageIndex":pageIndex, @"pageSize":pageSize}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articlesDetailWithArticleID:(NSString *)_id andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/detail" withParams:@{@"_id":_id}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articlesParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_comments_simpleWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/comments/simple" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_commentWithArticleID:(NSString *)article_id pageIndex:(NSNumber *)pageIndex pageSize:(NSNumber *)pageSize andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/comments" withParams:@{@"_id":article_id, @"pageIndex":pageIndex, @"pageSize":pageSize}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_commentWithArticleID:(NSString *)article_id content:(NSString *)content andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/comment" withParams:@{@"article_id":article_id, @"content":content}  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_collectWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/collect" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_related_witharticleWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/related/witharticle" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_comment_niceWithCommentID:(NSString *)comment_id andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/comment/nice" withParams:@{@"comment_id":comment_id}  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_articles_relatedWithArticleID:(NSString *)article_id andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/articles/related" withParams:@{@"article_id":article_id}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_notifications_unread_countAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notifications/count/unread" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_notification_typesWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notification/types" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_notificationsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notifications" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_notifications_readWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notifications/read" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_notifications_deleteWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notifications/delete" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_notifications_readallWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/notifications/readall" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - Version 2.0

#pragma mark - 首页
- (void)request_specialsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/specials" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_campaignsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/campaigns" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_labelsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/labels" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

//获取推荐服饰
- (void)request_recommend_productsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/recommend/products" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取可领取优惠券列表
- (void)request_promotionsAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/promotions" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取首页用户穿搭排名点评
- (void)request_home_social_rankAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/home/social/rank" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取首页杂志专区
- (void)request_home_articlesAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/home/articles" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取DRESSHERE精选
- (void)request_home_products_dresshereAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/home/products/dresshere" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取热门分类
- (void)request_home_categories_hotWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/home/categories/hot" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
//获取首页大咖点评
- (void)request_home_dianpingAndBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/home/dianping" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_guessyoulikeParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/guessyoulike" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_coverWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/cover" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_user_phone_modifyWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/user/phone/modify" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 动态
- (void)request_social_subscribeWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/subscribe" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
- (void)request_social_publishWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/publish" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_posts_squaresWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/posts/squares" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_postsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/posts" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_user_infoWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/user/info" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_brands_recommendsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/brands/recommends" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_productsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_discountsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/discounts" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

// GET 获取限量服装列表
- (void)request_products_limitedWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/limited" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}
// GET 获取特卖-好店内容
- (void)request_products_goodshopsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/goodshops" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

// GET 获取特卖-自营内容
- (void)request_products_dresshereWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/dresshere" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_products_dresshere_hybirdWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/products/dresshere/hybird" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_post_comments_simpleWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/post/comments/simple" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_post_niceWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/post/nice" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_post_commentWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/post/comment" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_post_comments_niceWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/post/comments/nice" withParams:params  withMethodType:Post autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_posts_commentsWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/posts/comments" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_fansWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/fans" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)request_social_subscribedWithParams:(NSDictionary *)params andBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/social/subscribed" withParams:params  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

#pragma mark - 获取阿里云临时权限
- (void)request_Aliyun_OSSSecretTokenWithBlock:(void (^)(id data, NSError *error))block{
    [self requestJsonDataWithPath:@"/getOSSSecretToken" withParams:@{}  withMethodType:Get autoShowError:YES andBlock:^(id data, NSError *error) {
        block(data, nil);
    }];
}

- (void)requestJsonDataWithPath:(NSString *)aPath
                     withParams:(id)params
                 withMethodType:(NetworkMethod)method
                  autoShowError:(BOOL)autoShowError
                       andBlock:(void (^)(id data, NSError *error))block{
    if (!aPath || aPath.length <= 0) {
        return;
    }
    
    //    NSData *postData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil];
    //    NSString *postJson = [[NSString alloc] initWithData:postData encoding:NSUTF8StringEncoding];
    //log请求数据
    NSLog(@"\n===========request===========\n%@\n%@:\n%@", kNetworkMethodName[method], aPath, params);
    aPath = [aPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //发起请求
    switch (method) {
        case Get:{
            //所有 Get 请求，增加缓存机制
            NSMutableString *localPath = [aPath mutableCopy];
            if (params) {
                //                [localPath appendString:params.description];
            }
            [self GET:aPath parameters:params progress:^(NSProgress * _Nonnull downloadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSLog(@"\n===========response===========\n%@:\n%@", aPath, responseObject);
//                BaseModel *model = [BaseModel modelWithJSON:responseObject];
                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)[task response];
//                | "100"  ; Section 10.1.1: Continue
//                | "101"  ; Section 10.1.2: Switching Protocols
//                | "200"  ; Section 10.2.1: OK
//                | "201"  ; Section 10.2.2: Created
//                | "202"  ; Section 10.2.3: Accepted
//                | "203"  ; Section 10.2.4: Non-Authoritative Information
//                | "204"  ; Section 10.2.5: No Content
//                | "205"  ; Section 10.2.6: Reset Content
//                | "206"  ; Section 10.2.7: Partial Content
//                | "300"  ; Section 10.3.1: Multiple Choices
//                | "301"  ; Section 10.3.2: Moved Permanently
//                | "302"  ; Section 10.3.3: Found
//                | "303"  ; Section 10.3.4: See Other
//                | "304"  ; Section 10.3.5: Not Modified
//                | "305"  ; Section 10.3.6: Use Proxy
//                | "307"  ; Section 10.3.8: Temporary Redirect
//                | "400"  ; Section 10.4.1: Bad Request
//                | "401"  ; Section 10.4.2: Unauthorized
//                | "402"  ; Section 10.4.3: Payment Required
//                | "403"  ; Section 10.4.4: Forbidden
//                | "404"  ; Section 10.4.5: Not Found
//                | "405"  ; Section 10.4.6: Method Not Allowed
//                | "406"  ; Section 10.4.7: Not Acceptable
                if (httpResponse.statusCode == 200) {
                    block(responseObject, nil);
                }
//                if ([model.status integerValue] == 200) {
//                    block(model.data, nil);
//                }else if ([model.status integerValue] == 401){
//                    [kAppDelegate configLoginController];
//                }else{
//                    [NSObject showHudTipStr:model.message];
//                }
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)[task response];
                if (httpResponse.statusCode == 401) {
                    [kAppDelegate configLoginController];
                }else{
                    NSData *errorData = [error.userInfo objectForKey:AFNetworkingOperationFailingURLResponseDataErrorKey];
                    NSString * str = [[NSString alloc] initWithData:errorData encoding:NSUTF8StringEncoding];
                    Error *serverError = [Error modelWithJSON:str];
                    NSLog(@"%@",str);
                    [NSObject showHudTipStr:serverError.error];
                    NSLog(@"\n===========response===========\n%@:\n%@\n%@", aPath, error, error);
                }
            }];
            break;}
        case Post:{
            [self POST:aPath parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSLog(@"\n===========response===========\n%@:\n%@", aPath, responseObject);
                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)[task response];
                if (httpResponse.statusCode == 200) {
                    block(responseObject, nil);
                }
//                if ([model.status integerValue] == 200 && model.data) {
//                    block(model.data, nil);
//                }else if ([model.status integerValue] == 401){
//                    [kAppDelegate configLoginController];
//                }else{
//                    [NSObject showHudTipStr:model.message];
//                }
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                
                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)[task response];
                if (httpResponse.statusCode == 401) {
                    [kAppDelegate configLoginController];
                }else{
                    NSData *errorData = [error.userInfo objectForKey:AFNetworkingOperationFailingURLResponseDataErrorKey];
                    NSString * str = [[NSString alloc] initWithData:errorData encoding:NSUTF8StringEncoding];
                    Error *serverError = [Error modelWithJSON:str];
                    NSLog(@"%@",str);
                    [NSObject showHudTipStr:serverError.error];
                    NSLog(@"\n===========response===========\n%@:\n%@\n%@", aPath, error, error);
                }
            }];
            break;}
        case Put:{

            break;}
        case Delete:{

            break;
        }
        default:
            break;
    }
}

@end
